﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using NDepot.Validations.Validators;

namespace NDepot.Validations
{
    public class DepotValidatorProvider : AssociatedValidatorProvider
    {
        protected override IEnumerable<ModelValidator> GetValidators(
            ModelMetadata metadata, ControllerContext context,
            IEnumerable<Attribute> attributes)
        {
            foreach (var attrib in attributes.OfType<EqualToPropertyAttribute>())
                yield return new EqualToPropertyValidator(metadata, context,
                attrib.CompareProperty);
        }
    }
}